/* eslint-disable */
import echarts from 'echarts/lib/echarts';
import Chart from 'echarts-for-react/lib/core';

// 饼图
export default function ChartPie({title = '', detail = {}}) {
  const option = {
    tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b}: {c} ({d}%)'
    },
    color : ["#43ff93", "#dfff92", "#fdba5b", "#00cce4", "#00aaf1", "#487cff", "#ff686f"],
    legend: {
      orient: 'vertical',
      icon: "circle",
      top: 15,
      right: 30,
      textStyle: {
        color: "#fff",
        padding: [0, 10, 0, 20],
      },
      formatter: name => `${name}    ${detail.legendData[name] && detail.legendData[name].ratio}`,
    },
    title: [
      {
        text: '21027',
        left: '22%',
        top: '32%',
        textStyle: {
          fontSize: 18,
          color: 'white',
        }
      }, {
        text: '产生量(万吨)',
        left: '20%',
        top: '48%',
        textStyle: {
          fontSize: 14,
          color: 'white',
        }
      }, {
        text: title,
        left: '16%',
        top: '81%',
        textStyle: {
          fontSize: 14,
          color: 'white',
        }
      },
    ],
    series: [
      {
        name: '',
        type: 'pie',
        radius: ['50%', '70%'],
        center: ["30%", "45%"],
        avoidLabelOverlap: false,
        label: {
          normal: {
            show: false,
          },
          emphasis: {
            show: true,
            textStyle: {
              fontSize: '12',
            }
          }
        },
        labelLine: {
          normal: {
            show: false
          }
        },
        data: detail.data,
      }
    ]
  };

  return (
    <div className='situational-detail'>
      <Chart
        echarts={echarts}
        option={option}
        notMerge
        lazyUpdate
        style={{ height: 190 }}
      />
    </div>
  )
}